package org.jeecg.modules.demo.rechargecardcost.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.rechargecardcost.entity.RechargeCardCost;
import org.jeecg.modules.demo.rechargecardcost.mapper.RechargeCardCostMapper;
import org.jeecg.modules.demo.rechargecardcost.service.IRechargeCardCostService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 充值卡费用设置表
 * @Author: jeecg-boot
 * @Date: 2022-02-14
 * @Version: V1.0
 */
@Service
public class RechargeCardCostServiceImpl extends ServiceImpl<RechargeCardCostMapper, RechargeCardCost> implements IRechargeCardCostService {

    @Override
    public Result<?> save1(RechargeCardCost rechargeCardCost) {

        if (rechargeCardCost.getYearCost() == null && rechargeCardCost.getHalfyearCost() == null && rechargeCardCost.getQuarterCost() == null && rechargeCardCost.getMonthCost() == null) {
            Result.error("至少要设置一个费用");
        }
        List<RechargeCardCost> list = list();
        if (list != null && list.size() > 0) {
            baseMapper.update1(rechargeCardCost);
        } else {
            baseMapper.insert1(rechargeCardCost);
        }
        return Result.OK("保存成功");
    }
}
